# Definition for a binary tree node.
# class TreeNode:
#     def __init__(self, x):
#         self.val = x
#         self.left = None
#         self.right = None
'''
1. return 0 作为返回条件,在每次递归的时候回加上深度1
2. 然后左边递归,右边也递归,取最大值就ok了
思路就是左右树递归，返回的时候max + 1 来记录深度就可以了
'''
class Solution:
    def maxDepth(self, root):
        if not root:
            return 0
        left = self.maxDepth(root.left)
        right = self.maxDepth(root.right)
        return max(left,right) + 1